#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 1e5 + 10;

int T;
int n, m, L, V;
int d[N], v[N], a[N];
int p[N];
int ans1, ans2;

int bsearch_1(int l, int r, double x)
{
    while (l < r)
    {
        int mid = l + r >> 1;
        if (x < p[mid]) r = mid;
        else l = mid + 1;
    }
    return l;
}

int bsearch_2(int l, int r, double x)
{
    while (l < r)
    {
        int mid = l + r >> 1;
        if (x < p[mid]) r = mid;
        else l = mid + 1;
    }
    return l;
}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &T);
    getchar();
    while (T -- )
    {
        scanf("%d%d%d%d", &n, &m, &L, &V);
        for (int i = 1; i <= n; i ++ )
        {
            scanf("%d%d%d", &d[i], &v[i], &a[i]);
        }
        for (int i = 1; i <= m; i ++ )
        {
            scanf("%d" ,&p[i]);
        }

        for (int i = 1; i <= n; i ++ )
        {
            if (a[i] == 0 && v[i] <= V) continue;
            double num = (double)(d[i] + ((V * V - v[i] * v[i]) / 2.0 / a[i]));
            if (a[i] == 0) ans1 ++ ;
            int x, y;
            if (a[i] > 0)
            {
                x= bsearch_1(1, n, num);
                ans1 ++ ;
            }
            if (a[i] < 0)
            {
                x = bsearch_1(1, n, d[i]);
                y = bsearch_1(1, n, num);
                if (x != y) ans1 ++ ;
            }
        }
        printf("%d %d\n", ans1, ans1);
    }
    return 0;
}
